package org.yuci.concurency.interrupt.case01;

import org.junit.Test;

public class GeneralInterruptTest {

    @Test
    public void test1() {
        GeneralInterrupt si = new GeneralInterrupt();
        si.setWorkId(1);
        
        Thread t = new Thread(si);
        t.start();
        try {
            Thread.sleep(2000);
        } catch (InterruptedException x) {
        }
        System.out.println("in main() - interrupting other thread");
        t.interrupt();
        System.out.println("in main() - leaving");
    }
    
    @Test
    public void test2() {
        GeneralInterrupt si = new GeneralInterrupt();
        si.setWorkId(2);
        
        Thread t = new Thread(si);
        t.start();
        try {
            Thread.sleep(2000);
        } catch (InterruptedException x) {
        }
        System.out.println("in main() - interrupting other thread");
        t.interrupt();
        System.out.println("in main() - leaving");
    }

}
